package sysu.el.array;

import sysu.el.array.ints.ArrInt;
import junit.framework.TestCase;

public class TagArrayTest extends TestCase {
	
	public void testTagArray(){
		
		int len = 100;
		TagArray tag = new TagArray(len);
		int tagNum = 5;
		
		for ( tagNum = 5; tagNum < len / 3; tagNum++){
			tag.reset(tagNum);
			for (int i=0; i<len; i++){
//				System.out.print(i % tagNum + "\t");
				tag.setTag(i, i % tagNum);
			}

			for (int i=1; i<len; i++){
				assertEquals(tag.getTag(i), i%tagNum);
			}

			ArrInt[] a = tag.getElemsWithTag(tagNum);
			for (int i=0; i<a.length; i++){
				System.out.println();
				for (int j=0; j<a[i].counter; j++){
					assertEquals (a[i].list[j]  % tagNum,  i);
//					System.out.print(a[i].list[j] + "\t");
				}
			}
		}
		
	}
}
